package io.mft.web.adapter.api.response;

import java.util.ArrayList;
import java.util.List;

import io.mft.commons.function.response.kv.KVMap;
import io.mft.runtime.function.ApiFunctionResponse;

public abstract class WebApiResponse extends KVMap {

	/**
	 * @说明：TODO
	 * @字段名称 serialVersionUID
	 */

	private static final long serialVersionUID = 3934958876143607601L;
	private List<String> dsName = new ArrayList<>();

	private WebApiResponse(int errorNo, String errorInfo) {
		setErrorNo(errorNo);
		setErrorInfo(errorInfo);
		set("dsName", dsName);
	}

	public WebApiResponse(ApiFunctionResponse response) {
		this(response.getErrorNo(), response.getErrorInfo());
	}
	public WebApiResponse() {
		this(0, "SUCCESS");
	}
	public abstract void setErrorNo(int errorNo);

	public abstract void setErrorInfo(String errorInfo);

	public void data(String key, Object value) {
		dsName.add(key);
		set(key, value);
	}

	public abstract void data(Object value);
}
